import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import get from '@dfeidao/atom-web/local/get';
import set from '@dfeidao/atom-web/local/set';
import javadsd from '@dfeidao/atom-web/msg/javadsd';
import tree from '@dfeidao/fd-w000001';

interface B {
	docDataStore: {
		master: {
			dataArray: [{
				no: string
				formid: string;
				grid_1: {
					dataArray: [
						{
							no: string;
							formid: string;
							formname: string;
							action_name: string;
							action_keyword: string;
						}
					]
				}
			}]
		};
	};
}
export default async function a007(fd: IFeidaoAiBrowserComponent, args: { target: HTMLElement }) {
	// 点击切换等级
	const productid1 = get(fd, 'productid');
	const clicknode = args.target;
	const list = fd.data.node.querySelectorAll<HTMLDivElement>('[levellist]');
	list.forEach((i) => {
		i.classList.remove('w-bg-themef');
	});
	clicknode.classList.add('w-bg-themef');
	const level_no1 = clicknode.getAttribute('level_no');
	set(fd, 'level_no111', level_no1);
	const select = fd.data.node.querySelector<HTMLSelectElement>('[select]');
	const index = select.options.selectedIndex;
	const client_type1 = select.options[index].value;
	const condition = {
		param: {
			productid: productid1,
			client_type: client_type1,
			level_no: level_no1

		}
	};
	const ret = await javadsd('12', '12', 'smart_securitydsd0000003', condition) as B;
	// debugger;
	const array = new Array();
	ret.docDataStore.master.dataArray.forEach((i) => {
		if (i.grid_1.dataArray.length > 0) {
			i.grid_1.dataArray.forEach((j) => {
				j.no = j.formid;
				j.formid = j.formid + j.action_keyword;
				j.formname = j.action_name;
				array.push(j.formid);
			});
		}
		delete i.grid_1;
		i.no = '';
		// if (!i.formid) {
		// 	i.formid = JSON.stringify(idex);
		// }
		array.push(i.formid);
	});
	const zds = fd.data.node.querySelector('[zds]') as tree;
	zds.uncheck_all();
	zds.check_node(array);
}
